home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / xshp15.zip / SHOWPAGE.ASM < prev    next >
Assembly Source File  |  1991-06-05  |  2KB  |  51 lines

  1. ; Shows the page at the specified offset in the bitmap. Page is
  2. ; displayed when this routine returns. This code first appeared in
  3. ; PC Techniques.
  4. ;
  5. ; C near-callable as: void ShowPage(unsigned int StartOffset);
  6.  
  7. INPUT_STATUS_1  equ     03dah   ;Input Status 1 register
  8. CRTC_INDEX      equ     03d4h   ;CRT Controller Index reg
  9. START_ADDRESS_HIGH equ  0ch     ;bitmap start address high byte
  10. START_ADDRESS_LOW equ   0dh     ;bitmap start address low byte
  11.  
  12. ShowPageParms   struc
  13.         dw      2 dup (?) ;pushed BP and return address
  14. StartOffset dw  ?       ;offset in bitmap of page to display
  15. ShowPageParms   ends
  16.  
  17.         .model  small
  18.         .code
  19.         public  _ShowPage
  20. _ShowPage       proc    near
  21.         push    bp      ;preserve caller's stack frame
  22.         mov     bp,sp   ;point to local stack frame
  23. ; Wait for display enable to be active (status is active low), to be
  24. ; sure both halves of the start address will take in the same frame.
  25.         mov     bl,START_ADDRESS_LOW        ;preload for fastest
  26.         mov     bh,byte ptr StartOffset[bp] ; flipping once display
  27.         mov     cl,START_ADDRESS_HIGH       ; enable is detected
  28.         mov     ch,byte ptr StartOffset+1[bp]
  29.         mov     dx,INPUT_STATUS_1
  30. WaitDE:
  31.         in      al,dx
  32.         test    al,01h
  33.         jnz     WaitDE  ;display enable is active low (0 = active)
  34. ; Set the start offset in display memory of the page to display.
  35.         mov     dx,CRTC_INDEX
  36.         mov     ax,bx
  37.         out     dx,ax   ;start address low
  38.         mov     ax,cx
  39.         out     dx,ax   ;start address high
  40. ; Now wait for vertical sync, so the other page will be invisible when
  41. ; we start drawing to it.
  42.         mov     dx,INPUT_STATUS_1
  43. WaitVS:
  44.         in      al,dx
  45.         test    al,08h
  46.         jz      WaitVS  ;vertical sync is active high (1 = active)
  47.         pop     bp      ;restore caller's stack frame
  48.         ret
  49. _ShowPage       endp
  50.         end
  51.